<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>EasyTalk 升级程序</title>
</head>
<body>
<p>感谢您使用 EasyTalk微博客软件，本程序是<b>EasyTalk X1.5 到 EasyTalk X1.6</b>的数据库升级程序</p>
<p>○ 请复制该程序到微博客的根目录下执行</p>
<p>○ 执行完成后请通过FTP删除改文件</p>
<?php
define('IN_ET',1);
$config=@include("config.inc.php");
@include("define.inc.php");

if ($_POST['action']=='update') {
    $conn=mysql_connect($config['DB_HOST'],$config['DB_USER'],$config['DB_PWD']);
    mysql_select_db($config['DB_NAME'],$conn);
    @mysql_query("set names utf8");

    $i=0;
    //system
    $query=mysql_query("SELECT * FROM ".$config['DB_PREFIX']."system");
    while($data=mysql_fetch_array($query)){
        $system[]=$data['name'];
    }
    if (!in_array('cachetime',$system)) {
        $i++;
        mysql_query("INSERT INTO `".$config['DB_PREFIX']."system` (`name` ,`title` ,`contents` ,`description`)VALUES ('cachetime', '客户端缓存更新', '20110101', '客户端缓存更新')");
    }
    //tables
    $query2=mysql_query("show tables");
    while($data2=mysql_fetch_array($query2)) {
        $users[]=$data2[0];
    }
    if (!in_array($config['DB_PREFIX']."atusers",$users)) {
        $i++;
        mysql_query("CREATE TABLE IF NOT EXISTS `".$config['DB_PREFIX']."atusers` (`id` INT( 10 ) NOT NULL AUTO_INCREMENT,`user_id` INT( 20 ) NOT NULL ,`atuname` VARCHAR( 20 ) NOT NULL ,`atnickname` VARCHAR( 20 ) NOT NULL ,`atnums` INT( 10 ) NOT NULL DEFAULT '1',`dateline` INT( 10 ) NOT NULL,PRIMARY KEY  (`id`)) ENGINE = MYISAM DEFAULT CHARSET=utf8");
    }

    if (!in_array($config['DB_PREFIX']."district",$users)) {
        $i++;
        mysql_query("CREATE TABLE IF NOT EXISTS `".$config['DB_PREFIX']."district` (`id` mediumint(8) unsigned NOT NULL auto_increment,`name` varchar(255) NOT NULL default '',`level` tinyint(4) unsigned NOT NULL default '0',`upid` mediumint(8) unsigned NOT NULL default '0',PRIMARY KEY  (`id`),KEY `upid` (`upid`)) ENGINE = MYISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=570");
    }

    $i=$i+2;
    mysql_query("TRUNCATE TABLE `".$config['DB_PREFIX']."gametuijian`");
    mysql_query("INSERT INTO `".$config['DB_PREFIX']."district` (`id`, `name`, `level`, `upid`) VALUES
    (1, '北京市', 1, 0),
    (2, '天津市', 1, 0),
    (3, '河北省', 1, 0),
    (4, '山西省', 1, 0),
    (5, '内蒙古省', 1, 0),
    (6, '辽宁省', 1, 0),
    (7, '吉林省', 1, 0),
    (8, '黑龙江省', 1, 0),
    (9, '上海市', 1, 0),
    (10, '江苏省', 1, 0),
    (11, '浙江省', 1, 0),
    (12, '安徽省', 1, 0),
    (13, '福建省', 1, 0),
    (14, '江西省', 1, 0),
    (15, '山东省', 1, 0),
    (16, '河南省', 1, 0),
    (17, '湖北省', 1, 0),
    (18, '湖南省', 1, 0),
    (19, '广东省', 1, 0),
    (20, '广西省', 1, 0),
    (21, '海南省', 1, 0),
    (22, '重庆市', 1, 0),
    (23, '四川省', 1, 0),
    (24, '贵州省', 1, 0),
    (25, '云南省', 1, 0),
    (26, '西藏省', 1, 0),
    (27, '陕西省', 1, 0),
    (28, '甘肃省', 1, 0),
    (29, '青海省', 1, 0),
    (30, '宁夏省', 1, 0),
    (31, '新疆省', 1, 0),
    (32, '台湾省', 1, 0),
    (33, '香港', 1, 0),
    (34, '澳门', 1, 0),
    (35, '海外', 1, 0),
    (36, '其他', 1, 0),
    (37, '东城区', 2, 1),
    (38, '西城区', 2, 1),
    (39, '崇文区', 2, 1),
    (40, '宣武区', 2, 1),
    (41, '朝阳区', 2, 1),
    (42, '丰台区', 2, 1),
    (43, '石景山区', 2, 1),
    (44, '海淀区', 2, 1),
    (45, '门头沟区', 2, 1),
    (46, '房山区', 2, 1),
    (47, '通州区', 2, 1),
    (48, '顺义区', 2, 1),
    (49, '昌平区', 2, 1),
    (50, '大兴区', 2, 1),
    (51, '怀柔区', 2, 1),
    (52, '平谷区', 2, 1),
    (53, '密云县', 2, 1),
    (54, '延庆县', 2, 1),
    (55, '和平区', 2, 2),
    (56, '河东区', 2, 2),
    (57, '河西区', 2, 2),
    (58, '南开区', 2, 2),
    (59, '河北区', 2, 2),
    (60, '红桥区', 2, 2),
    (61, '塘沽区', 2, 2),
    (62, '汉沽区', 2, 2),
    (63, '大港区', 2, 2),
    (64, '东丽区', 2, 2),
    (65, '西青区', 2, 2),
    (66, '津南区', 2, 2),
    (67, '北辰区', 2, 2),
    (68, '武清区', 2, 2),
    (69, '宝坻区', 2, 2),
    (70, '宁河县', 2, 2),
    (71, '静海县', 2, 2),
    (72, '蓟县', 2, 2),
    (73, '石家庄市', 2, 3),
    (74, '唐山市', 2, 3),
    (75, '秦皇岛市', 2, 3),
    (76, '邯郸市', 2, 3),
    (77, '邢台市', 2, 3),
    (78, '保定市', 2, 3),
    (79, '张家口市', 2, 3),
    (80, '承德市', 2, 3),
    (81, '衡水市', 2, 3),
    (82, '廊坊市', 2, 3),
    (83, '沧州市', 2, 3),
    (84, '太原市', 2, 4),
    (85, '大同市', 2, 4),
    (86, '阳泉市', 2, 4),
    (87, '长治市', 2, 4),
    (88, '晋城市', 2, 4),
    (89, '朔州市', 2, 4),
    (90, '晋中市', 2, 4),
    (91, '运城市', 2, 4),
    (92, '忻州市', 2, 4),
    (93, '临汾市', 2, 4),
    (94, '吕梁市', 2, 4),
    (95, '呼和浩特市', 2, 5),
    (96, '包头市', 2, 5),
    (97, '乌海市', 2, 5),
    (98, '赤峰市', 2, 5),
    (99, '通辽市', 2, 5),
    (100, '鄂尔多斯市', 2, 5),
    (101, '呼伦贝尔市', 2, 5),
    (102, '巴彦淖尔市', 2, 5),
    (103, '乌兰察布市', 2, 5),
    (104, '兴安盟', 2, 5),
    (105, '锡林郭勒盟', 2, 5),
    (106, '阿拉善盟', 2, 5),
    (107, '沈阳市', 2, 6),
    (108, '大连市', 2, 6),
    (109, '鞍山市', 2, 6),
    (110, '抚顺市', 2, 6),
    (111, '本溪市', 2, 6),
    (112, '丹东市', 2, 6),
    (113, '锦州市', 2, 6),
    (114, '营口市', 2, 6),
    (115, '阜新市', 2, 6),
    (116, '辽阳市', 2, 6),
    (117, '盘锦市', 2, 6),
    (118, '铁岭市', 2, 6),
    (119, '朝阳市', 2, 6),
    (120, '葫芦岛市', 2, 6),
    (121, '长春市', 2, 7),
    (122, '吉林市', 2, 7),
    (123, '四平市', 2, 7),
    (124, '辽源市', 2, 7),
    (125, '通化市', 2, 7),
    (126, '白山市', 2, 7),
    (127, '松原市', 2, 7),
    (128, '白城市', 2, 7),
    (129, '延边', 2, 7),
    (130, '哈尔滨市', 2, 8),
    (131, '齐齐哈尔市', 2, 8),
    (132, '鸡西市', 2, 8),
    (133, '鹤岗市', 2, 8),
    (134, '双鸭山市', 2, 8),
    (135, '大庆市', 2, 8),
    (136, '伊春市', 2, 8),
    (137, '佳木斯市', 2, 8),
    (138, '七台河市', 2, 8),
    (139, '牡丹江市', 2, 8),
    (140, '黑河市', 2, 8),
    (141, '绥化市', 2, 8),
    (142, '大兴安岭', 2, 8),
    (143, '黄浦区', 2, 9),
    (144, '卢湾区', 2, 9),
    (145, '徐汇区', 2, 9),
    (146, '长宁区', 2, 9),
    (147, '静安区', 2, 9),
    (148, '普陀区', 2, 9),
    (149, '闸北区', 2, 9),
    (150, '虹口区', 2, 9),
    (151, '杨浦区', 2, 9),
    (152, '闵行区', 2, 9),
    (153, '宝山区', 2, 9),
    (154, '嘉定区', 2, 9),
    (155, '浦东新区', 2, 9),
    (156, '金山区', 2, 9),
    (157, '松江区', 2, 9),
    (158, '青浦区', 2, 9),
    (159, '南汇区', 2, 9),
    (160, '奉贤区', 2, 9),
    (161, '崇明县', 2, 9),
    (162, '南京市', 2, 10),
    (163, '无锡市', 2, 10),
    (164, '徐州市', 2, 10),
    (165, '常州市', 2, 10),
    (166, '苏州市', 2, 10),
    (167, '南通市', 2, 10),
    (168, '连云港市', 2, 10),
    (169, '淮安市', 2, 10),
    (170, '盐城市', 2, 10),
    (171, '扬州市', 2, 10),
    (172, '镇江市', 2, 10),
    (173, '泰州市', 2, 10),
    (174, '宿迁市', 2, 10),
    (175, '杭州市', 2, 11),
    (176, '宁波市', 2, 11),
    (177, '温州市', 2, 11),
    (178, '嘉兴市', 2, 11),
    (179, '湖州市', 2, 11),
    (180, '绍兴市', 2, 11),
    (181, '舟山市', 2, 11),
    (182, '衢州市', 2, 11),
    (183, '金华市', 2, 11),
    (184, '台州市', 2, 11),
    (185, '丽水市', 2, 11),
    (186, '合肥市', 2, 12),
    (187, '芜湖市', 2, 12),
    (188, '蚌埠市', 2, 12),
    (189, '淮南市', 2, 12),
    (190, '马鞍山市', 2, 12),
    (191, '淮北市', 2, 12),
    (192, '铜陵市', 2, 12),
    (193, '安庆市', 2, 12),
    (194, '黄山市', 2, 12),
    (195, '滁州市', 2, 12),
    (196, '阜阳市', 2, 12),
    (197, '宿州市', 2, 12),
    (198, '巢湖市', 2, 12),
    (199, '六安市', 2, 12),
    (200, '亳州市', 2, 12),
    (201, '池州市', 2, 12),
    (202, '宣城市', 2, 12),
    (203, '福州市', 2, 13),
    (204, '厦门市', 2, 13),
    (205, '莆田市', 2, 13),
    (206, '三明市', 2, 13),
    (207, '泉州市', 2, 13),
    (208, '漳州市', 2, 13),
    (209, '南平市', 2, 13),
    (210, '龙岩市', 2, 13),
    (211, '宁德市', 2, 13),
    (212, '南昌市', 2, 14),
    (213, '景德镇市', 2, 14),
    (214, '萍乡市', 2, 14),
    (215, '九江市', 2, 14),
    (216, '新余市', 2, 14),
    (217, '鹰潭市', 2, 14),
    (218, '赣州市', 2, 14),
    (219, '吉安市', 2, 14),
    (220, '宜春市', 2, 14),
    (221, '抚州市', 2, 14),
    (222, '上饶市', 2, 14),
    (223, '济南市', 2, 15),
    (224, '青岛市', 2, 15),
    (225, '淄博市', 2, 15),
    (226, '枣庄市', 2, 15),
    (227, '东营市', 2, 15),
    (228, '烟台市', 2, 15),
    (229, '潍坊市', 2, 15),
    (230, '济宁市', 2, 15),
    (231, '泰安市', 2, 15),
    (232, '威海市', 2, 15),
    (233, '日照市', 2, 15),
    (234, '莱芜市', 2, 15),
    (235, '临沂市', 2, 15),
    (236, '德州市', 2, 15),
    (237, '聊城市', 2, 15),
    (238, '滨州市', 2, 15),
    (239, '菏泽市', 2, 15),
    (240, '郑州市', 2, 16),
    (241, '开封市', 2, 16),
    (242, '洛阳市', 2, 16),
    (243, '平顶山市', 2, 16),
    (244, '安阳市', 2, 16),
    (245, '鹤壁市', 2, 16),
    (246, '新乡市', 2, 16),
    (247, '焦作市', 2, 16),
    (248, '濮阳市', 2, 16),
    (249, '许昌市', 2, 16),
    (250, '漯河市', 2, 16),
    (251, '三门峡市', 2, 16),
    (252, '南阳市', 2, 16),
    (253, '商丘市', 2, 16),
    (254, '信阳市', 2, 16),
    (255, '周口市', 2, 16),
    (256, '驻马店市', 2, 16),
    (257, '济源市', 2, 16),
    (258, '武汉市', 2, 17),
    (259, '黄石市', 2, 17),
    (260, '十堰市', 2, 17),
    (261, '宜昌市', 2, 17),
    (262, '襄樊市', 2, 17),
    (263, '鄂州市', 2, 17),
    (264, '荆门市', 2, 17),
    (265, '孝感市', 2, 17),
    (266, '荆州市', 2, 17),
    (267, '黄冈市', 2, 17),
    (268, '咸宁市', 2, 17),
    (269, '随州市', 2, 17),
    (270, '恩施州', 2, 17),
    (271, '仙桃市', 2, 17),
    (272, '潜江市', 2, 17),
    (273, '天门市', 2, 17),
    (274, '神农架林区', 2, 17),
    (275, '长沙市', 2, 18),
    (276, '株洲市', 2, 18),
    (277, '湘潭市', 2, 18),
    (278, '衡阳市', 2, 18),
    (279, '邵阳市', 2, 18),
    (280, '岳阳市', 2, 18),
    (281, '常德市', 2, 18),
    (282, '张家界市', 2, 18),
    (283, '益阳市', 2, 18),
    (284, '郴州市', 2, 18),
    (285, '永州市', 2, 18),
    (286, '怀化市', 2, 18),
    (287, '娄底市', 2, 18),
    (288, '湘西州', 2, 18),
    (289, '广州市', 2, 19),
    (290, '韶关市', 2, 19),
    (291, '深圳市', 2, 19),
    (292, '珠海市', 2, 19),
    (293, '汕头市', 2, 19),
    (294, '佛山市', 2, 19),
    (295, '江门市', 2, 19),
    (296, '湛江市', 2, 19),
    (297, '茂名市', 2, 19),
    (298, '肇庆市', 2, 19),
    (299, '惠州市', 2, 19),
    (300, '梅州市', 2, 19),
    (301, '汕尾市', 2, 19),
    (302, '河源市', 2, 19),
    (303, '阳江市', 2, 19),
    (304, '清远市', 2, 19),
    (305, '东莞市', 2, 19),
    (306, '中山市', 2, 19),
    (307, '潮州市', 2, 19),
    (308, '揭阳市', 2, 19),
    (309, '云浮市', 2, 19),
    (310, '南宁市', 2, 20),
    (311, '柳州市', 2, 20),
    (312, '桂林市', 2, 20),
    (313, '梧州市', 2, 20),
    (314, '北海市', 2, 20),
    (315, '防城港市', 2, 20),
    (316, '钦州市', 2, 20),
    (317, '贵港市', 2, 20),
    (318, '玉林市', 2, 20),
    (319, '百色市', 2, 20),
    (320, '贺州市', 2, 20),
    (321, '河池市', 2, 20),
    (322, '来宾市', 2, 20),
    (323, '崇左市', 2, 20),
    (324, '海口市', 2, 21),
    (325, '三亚市', 2, 21),
    (326, '五指山市', 2, 21),
    (327, '琼海市', 2, 21),
    (328, '儋州市', 2, 21),
    (329, '文昌市', 2, 21),
    (330, '万宁市', 2, 21),
    (331, '东方市', 2, 21),
    (332, '定安县', 2, 21),
    (333, '屯昌县', 2, 21),
    (334, '澄迈县', 2, 21),
    (335, '临高县', 2, 21),
    (336, '白沙县', 2, 21),
    (337, '昌江县', 2, 21),
    (338, '乐东县', 2, 21),
    (339, '陵水黎族自治县', 2, 21),
    (340, '保亭县', 2, 21),
    (341, '琼中县', 2, 21),
    (342, '西沙群岛', 2, 21),
    (343, '南沙群岛', 2, 21),
    (344, '中沙群岛', 2, 21),
    (345, '万州区', 2, 22),
    (346, '涪陵区', 2, 22),
    (347, '渝中区', 2, 22),
    (348, '大渡口区', 2, 22),
    (349, '江北区', 2, 22),
    (350, '沙坪坝区', 2, 22),
    (351, '九龙坡区', 2, 22),
    (352, '南岸区', 2, 22),
    (353, '北碚区', 2, 22),
    (354, '双桥区', 2, 22),
    (355, '万盛区', 2, 22),
    (356, '渝北区', 2, 22),
    (357, '巴南区', 2, 22),
    (358, '黔江区', 2, 22),
    (359, '长寿区', 2, 22),
    (360, '綦江县', 2, 22),
    (361, '潼南县', 2, 22),
    (362, '铜梁县', 2, 22),
    (363, '大足县', 2, 22),
    (364, '荣昌县', 2, 22),
    (365, '璧山县', 2, 22),
    (366, '梁平县', 2, 22),
    (367, '城口县', 2, 22),
    (368, '丰都县', 2, 22),
    (369, '垫江县', 2, 22),
    (370, '武隆县', 2, 22),
    (371, '忠县', 2, 22),
    (372, '开县', 2, 22),
    (373, '云阳县', 2, 22),
    (374, '奉节县', 2, 22),
    (375, '巫山县', 2, 22),
    (376, '巫溪县', 2, 22),
    (377, '石柱县', 2, 22),
    (378, '秀山县', 2, 22),
    (379, '酉阳县', 2, 22),
    (380, '彭水县', 2, 22),
    (381, '江津市', 2, 22),
    (382, '合川市', 2, 22),
    (383, '永川市', 2, 22),
    (384, '南川市', 2, 22),
    (385, '成都市', 2, 23),
    (386, '自贡市', 2, 23),
    (387, '攀枝花市', 2, 23),
    (388, '泸州市', 2, 23),
    (389, '德阳市', 2, 23),
    (390, '绵阳市', 2, 23),
    (391, '广元市', 2, 23),
    (392, '遂宁市', 2, 23),
    (393, '内江市', 2, 23),
    (394, '乐山市', 2, 23),
    (395, '南充市', 2, 23),
    (396, '眉山市', 2, 23),
    (397, '宜宾市', 2, 23),
    (398, '广安市', 2, 23),
    (399, '达州市', 2, 23),
    (400, '雅安市', 2, 23),
    (401, '巴中市', 2, 23),
    (402, '资阳市', 2, 23),
    (403, '阿坝州', 2, 23),
    (404, '甘孜州', 2, 23),
    (405, '凉山州', 2, 23),
    (406, '贵阳市', 2, 24),
    (407, '六盘水市', 2, 24),
    (408, '遵义市', 2, 24),
    (409, '安顺市', 2, 24),
    (410, '铜仁地区', 2, 24),
    (411, '黔西南州', 2, 24),
    (412, '毕节地区', 2, 24),
    (413, '黔东南州', 2, 24),
    (414, '黔南州', 2, 24),
    (415, '昆明市', 2, 25),
    (416, '曲靖市', 2, 25),
    (417, '玉溪市', 2, 25),
    (418, '保山市', 2, 25),
    (419, '昭通市', 2, 25),
    (420, '丽江市', 2, 25),
    (421, '思茅市', 2, 25),
    (422, '临沧市', 2, 25),
    (423, '楚雄州', 2, 25),
    (424, '红河州', 2, 25),
    (425, '文山州', 2, 25),
    (426, '西双版纳州', 2, 25),
    (427, '大理州', 2, 25),
    (428, '德宏州', 2, 25),
    (429, '怒江州', 2, 25),
    (430, '迪庆州', 2, 25),
    (431, '拉萨市', 2, 26),
    (432, '昌都地区', 2, 26),
    (433, '山南地区', 2, 26),
    (434, '日喀则地区', 2, 26),
    (435, '那曲地区', 2, 26),
    (436, '阿里地区', 2, 26),
    (437, '林芝地区', 2, 26),
    (438, '西安市', 2, 27),
    (439, '铜川市', 2, 27),
    (440, '宝鸡市', 2, 27),
    (441, '咸阳市', 2, 27),
    (442, '渭南市', 2, 27),
    (443, '延安市', 2, 27),
    (444, '汉中市', 2, 27),
    (445, '榆林市', 2, 27),
    (446, '安康市', 2, 27),
    (447, '商洛市', 2, 27),
    (448, '兰州市', 2, 28),
    (449, '嘉峪关市', 2, 28),
    (450, '金昌市', 2, 28),
    (451, '白银市', 2, 28),
    (452, '天水市', 2, 28),
    (453, '武威市', 2, 28),
    (454, '张掖市', 2, 28),
    (455, '平凉市', 2, 28),
    (456, '酒泉市', 2, 28),
    (457, '庆阳市', 2, 28),
    (458, '定西市', 2, 28),
    (459, '陇南市', 2, 28),
    (460, '临夏州', 2, 28),
    (461, '甘南州', 2, 28),
    (462, '西宁市', 2, 29),
    (463, '海东地区', 2, 29),
    (464, '海北州', 2, 29),
    (465, '黄南州', 2, 29),
    (466, '海南州', 2, 29),
    (467, '果洛州', 2, 29),
    (468, '玉树州', 2, 29),
    (469, '海西州', 2, 29),
    (470, '银川市', 2, 30),
    (471, '石嘴山市', 2, 30),
    (472, '吴忠市', 2, 30),
    (473, '固原市', 2, 30),
    (474, '中卫市', 2, 30),
    (475, '乌鲁木齐市', 2, 31),
    (476, '克拉玛依市', 2, 31),
    (477, '吐鲁番地区', 2, 31),
    (478, '哈密地区', 2, 31),
    (479, '昌吉州', 2, 31),
    (480, '博尔塔拉州', 2, 31),
    (481, '巴音郭楞州', 2, 31),
    (482, '阿克苏地区', 2, 31),
    (483, '克孜勒苏柯尔克孜州', 2, 31),
    (484, '喀什地区', 2, 31),
    (485, '和田地区', 2, 31),
    (486, '伊犁哈萨克州', 2, 31),
    (487, '塔城地区', 2, 31),
    (488, '阿勒泰地区', 2, 31),
    (489, '石河子市', 2, 31),
    (490, '阿拉尔市', 2, 31),
    (491, '图木舒克市', 2, 31),
    (492, '五家渠市', 2, 31),
    (493, '台北市', 2, 32),
    (494, '高雄市', 2, 32),
    (495, '基隆市', 2, 32),
    (496, '台中市', 2, 32),
    (497, '台南市', 2, 32),
    (498, '新竹市', 2, 32),
    (499, '嘉义市', 2, 32),
    (500, '台北县', 2, 32),
    (501, '宜兰县', 2, 32),
    (502, '桃园县', 2, 32),
    (503, '新竹县', 2, 32),
    (504, '苗栗县', 2, 32),
    (505, '台中县', 2, 32),
    (506, '彰化县', 2, 32),
    (507, '南投县', 2, 32),
    (508, '云林县', 2, 32),
    (509, '嘉义县', 2, 32),
    (510, '台南县', 2, 32),
    (511, '高雄县', 2, 32),
    (512, '屏东县', 2, 32),
    (513, '澎湖县', 2, 32),
    (514, '台东县', 2, 32),
    (515, '花莲县', 2, 32),
    (516, '中西区', 2, 33),
    (517, '东区', 2, 33),
    (518, '九龙城区', 2, 33),
    (519, '观塘区', 2, 33),
    (520, '南区', 2, 33),
    (521, '深水埗区', 2, 33),
    (522, '黄大仙区', 2, 33),
    (523, '湾仔区', 2, 33),
    (524, '油尖旺区', 2, 33),
    (525, '离岛区', 2, 33),
    (526, '葵青区', 2, 33),
    (527, '北区', 2, 33),
    (528, '西贡区', 2, 33),
    (529, '沙田区', 2, 33),
    (530, '屯门区', 2, 33),
    (531, '大埔区', 2, 33),
    (532, '荃湾区', 2, 33),
    (533, '元朗区', 2, 33),
    (534, '澳门', 2, 34),
    (535, '美国', 2, 35),
    (536, '加拿大', 2, 35),
    (537, '澳大利亚', 2, 35),
    (538, '新西兰', 2, 35),
    (539, '英国', 2, 35),
    (540, '法国', 2, 35),
    (541, '德国', 2, 35),
    (542, '捷克', 2, 35),
    (543, '荷兰', 2, 35),
    (544, '瑞士', 2, 35),
    (545, '希腊', 2, 35),
    (546, '挪威', 2, 35),
    (547, '瑞典', 2, 35),
    (548, '丹麦', 2, 35),
    (549, '芬兰', 2, 35),
    (550, '爱尔兰', 2, 35),
    (551, '奥地利', 2, 35),
    (552, '意大利', 2, 35),
    (553, '乌克兰', 2, 35),
    (554, '俄罗斯', 2, 35),
    (555, '西班牙', 2, 35),
    (556, '韩国', 2, 35),
    (557, '新加坡', 2, 35),
    (558, '马来西亚', 2, 35),
    (559, '印度', 2, 35),
    (560, '泰国', 2, 35),
    (561, '日本', 2, 35),
    (562, '巴西', 2, 35),
    (563, '阿根廷', 2, 35),
    (564, '南非', 2, 35),
    (565, '埃及', 2, 35),
    (566, '其他', 2, 36)");

    if (ET_VESION && ET_RELEASE && (strtolower(ET_VESION)!='x1.6' || ET_RELEASE!='20110624')) {
        save_config();
    }
    delcache();
    if ($i>0) {
        echo '<b><font color="red">恭喜您，升级成功，共执行了 '.$i.' 条升级语句！</font></b>';
    } else {
        echo '<b><font color="red">您的程序已经升级过，不需要再次升级！</font></b>';
    }
    exit;
}

function delcache() {
    clearcache('./Home/Runtime');
    clearcache('./Admin/Runtime');
    mkdir('./Home/Runtime');
    mkdir('./Admin/Runtime');
    mkdir('./Home/Runtime/Cache');
    mkdir('./Home/Runtime/Data');
    mkdir('./Home/Runtime/Logs');
    mkdir('./Home/Runtime/Temp');
    mkdir('./Admin/Runtime/Cache');
    mkdir('./Admin/Runtime/Data');
    mkdir('./Admin/Runtime/Logs');
    mkdir('./Admin/Runtime/Temp');
}

function clearcache($dirName){
    if(!is_dir($dirName)){
        @unlink($dirName);
        return false;
    }
    $handle = @opendir($dirName);
    while(($file = @readdir($handle)) !== false){
        if($file != '.' && $file != '..'){
            $dir = $dirName . '/' . $file;
            is_dir($dir) ? clearcache($dir) : @unlink($dir);
        }
    }
    closedir($handle);
    return rmdir($dirName);
}

function save_config() {
	$config = "<?php
    if (!defined('IN_ET')) exit();

    // ucenter config
    define('UC_CONNECT', '".UC_CONNECT."');
    define('UC_DBHOST', '".UC_DBHOST."');
    define('UC_DBUSER', '".UC_DBUSER."');
    define('UC_DBPW', '".UC_DBPW."');
    define('UC_DBNAME', '".UC_DBNAME."');
    define('UC_DBCHARSET', '".UC_DBCHARSET."');
    define('UC_DBTABLEPRE', '".UC_DBTABLEPRE."');
    define('UC_DBCONNECT', ".UC_DBCONNECT.");
    define('UC_CHARSET', '".UC_CHARSET."');
    define('UC_KEY', '".UC_KEY."');
    define('UC_API', '".UC_API."');
    define('UC_APPID', '".UC_APPID."');
    define('UC_IP', '".UC_IP."');
    define('UC_PPP', ".UC_PPP.");

    define('ADMIN_UID', ".ADMIN_UID.");

    // vesion
    define('ET_VESION', 'X1.6');
    define('ET_RELEASE', '20110624');

    // global config
    define('ET_UC', ".(ET_UC?'TRUE':'FALSE').");                      //是否开启ucenter ，开启填写 TRUE ，关闭 填写 FALSE
    define('ET_URL','".ET_URL."');
    ?>";

	if($fp = fopen('./define.inc.php', 'w')) {
		fwrite($fp, $config);
		fclose($fp);
	}
}
?>
<?php
if (!is_array($config)) {
    echo '<b>请将该文件放置在微博客的根目录下执行</b>';
} else {
?>
<form action="update1.6.php" method="post">
<input type="hidden" name="action" value="update">
<input type="submit" value="点击升级">
</form>
<?php
}
?>
</body>
</html>